package com.jic.market.controller.rest;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.api.rest.PromotionRestApi;
import com.jic.market.request.PromotionPolymericRequest;
import com.jic.market.request.rest.promotion.PromotionInfoRestRequest;
import com.jic.market.response.PromotionPolymericResponse;
import com.jic.market.response.rest.promotion.PromotionDetailRestResponse;
import com.jic.market.response.rest.promotion.PromotionGoodsSpuRestResponse;
import com.jic.market.response.rest.promotion.PromotionInfoRestResponse;
import com.jic.market.service.rest.promotion.PromotionRestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * description: PromotionRestController
 * date: 2020/4/8 10:11
 * author: wangys
 * version: 1.0
 */
@RestController
@RequestMapping("/rest/promotion")
@Api(tags = {"活动H5接口"})
@Slf4j
public class PromotionRestController implements PromotionRestApi {

    @Autowired
    PromotionRestService promotionRestService;

    @Override
    @ApiOperation(value = "根据商品列表查询参加的活动列表接口")
    @PostMapping("getPromotinInfos")
    public RestResult<List<PromotionInfoRestResponse>> getPromotinInfos(@RequestBody PromotionInfoRestRequest request) {
        // 满额，单一，单品X,赠送，组合，换购，满量，预售，秒杀（包含拼团，拼团详情，列表，参团等其他接口不包含）
        return RestResult.success(promotionRestService.getPromotinInfos(request));
    }

    @Override
    @ApiOperation(value = "当前商品参与活动列表")
    @PostMapping("getPromotinInfo")
    public RestResult<PromotionInfoRestResponse> getPromotinInfo(@RequestBody PromotionInfoRestRequest request) {
        // 满额，单一，单品X,赠送，组合，换购，满量，预售，秒杀（包含拼团，拼团详情，列表，参团等其他接口不包含）
        return RestResult.success(promotionRestService.getPromotinInfo(request));
    }

    @Override
    @ApiOperation(value = "活动详情")
    @PostMapping("promotionDetail")
    public RestResult<PromotionDetailRestResponse> promotionDetail(@RequestBody PromotionInfoRestRequest request) {
        return RestResult.success(promotionRestService.promotionDetail(request));
    }

    @Override
    @ApiOperation(value = "根据promotionCode查询参与的商品列表")
    @PostMapping("getGoodsByPromotionCode")
    public RestResult<PageResult<PromotionGoodsSpuRestResponse>> getGoodsByPromotionCode(@RequestBody PromotionInfoRestRequest request) {
        return RestResult.success(promotionRestService.getGoodsByPromotionCode(request));
    }

    @ApiOperation(value = "根据promotionCode查询参与的商品列表")
    @PostMapping("queryPromotionPolymericInfo")
    public RestResult<PromotionPolymericResponse> queryPromotionPolymericInfo(@RequestBody PromotionPolymericRequest request){

        return promotionRestService.queryPromotionPolymericInfo(request);
    }
}
